package org.ee.core.config;

import org.ee.core.filter.PrettyRequestLoggingFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

/**
 * 请求过滤器
 * @Author jokr
 * @Date 2025/8/29 10:31
 */
@Configuration
public class RequestLoggingConfig {

    /**
     * 配置请求过滤器，形成日志 ，配置request-logging
     * 在applicaton.yml配置
     * request-logging:
     *   enabled: true
     * 默认不启用
     * @return
     */
    @Bean
    @ConditionalOnProperty(prefix = "request-logging",name="enabled",havingValue = "true",matchIfMissing = false)
    public CommonsRequestLoggingFilter logFilter() {
        return new PrettyRequestLoggingFilter();
    }
}